package com.up.interview.flowable.other;

/**
 * @author: liuchengjun
 * @title: NotifyDelegate
 * @projectName: 海联技术中台V2.0
 * @depart 软件事业部
 * @description:
 * @date: 2025/10/30/周四 16:14 (星期四)
 * @since V2.0
 */

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/**
 * 通知员工的委托类
 * 在实际项目中,这里可以发送邮件、短信等
 */
@Slf4j
@Component
public class NotifyDelegate implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) {
        String employee = (String) execution.getVariable("employee");
        Integer days = (Integer) execution.getVariable("days");
        Boolean approved = (Boolean) execution.getVariable("approved");

        // 模拟发送通知
        if (approved == null || approved) {
            log.info("=== 通知员工 {} ===", employee);
            log.info("您的 {} 天请假申请已批准！", days);
        } else {
            log.info("=== 通知员工 {} ===", employee);
            log.info("您的 {} 天请假申请被拒绝！", days);
        }

        // 实际应用中可以：
        // 1. 发送邮件
        // 2. 发送短信
        // 3. 推送站内消息
        // 4. 调用其他系统API
    }
}
